<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>事件处理</title>
</head>
<body>
  <div id="app"></div>
  <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
  <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
  <!-- 使用jsx需要babel转义 -->
  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
  <!-- 使用babel需要申明type -->
  <script type="text/babel">
    const tag = document.getElementById('app')
    class Button extends React.Component{
      doClick(e) {
        alert('点击了')
        // react阻止默认行为
        e.preventDefault()
        // 阻止默认行为行不通
        // return false
      }
      render() {
        return <a href="http://www.baidu.com" onClick={this.doClick}>click me</a>
      }
      // render() {
      //   return <button onClick={this.doClick}>click me</button>
      // }
    }
    ReactDOM.render(
      <Button />,
      tag
    )
  </script>
</body>
</html>